package Flap::App::Web::Controller;
use Flap qw/-b Flap::Object -m -s -w/;

use constant ACTION_ARGS => {};

sub MODIFY_CODE_ATTRIBUTES {
    my($class, $code) = (shift, shift);
    my(@invalid, %arg);
    foreach(@_){
        next if !/^Action(?:\(([\w,]+)\))?\z/ && push(@invalid, $_);
        next if !defined($1);
        $arg{$_} = 1 for split(/,/, $1);
    }
    return @invalid if @invalid;
    $class->ACTION_ARGS->{$code} = \%arg;
    return;
}

sub NAME { substr($_[0], rindex($_[0], '::Controller::') + 14) }

sub PATH {
    my $n = $_[0]->NAME;
    $n eq 'Root' ? '/' : '/'.$_[0]->Util->class2path($n).'/';
}

1;
